#include "Stdmain.h"
#include "Matrix.h"

const int NFIT=6;

int main() 
{
  myvector<double> r,xip,xim,varxi;
  double r0,xip0,xim0,varxi0,xipm0,xipm1;
  string junk;
  while (cin>>junk>>r0>>xip0>>varxi0>>xim0>>junk>>junk>>junk>>
              junk>>junk>>junk>>junk>>xipm0>>xipm1>>junk) {
    r.push_back(r0);
    xip.push_back(xip0);
    varxi.push_back(varxi0+SQR(xipm0)+SQR(xipm1));
    xim.push_back(xim0);
  }
  SqDMatrix A(NFIT);
  DVector B(NFIT);
  DVector C(NFIT);
  for(uint i=0;i<r.size();i++) if (r[i]>0.5 && r[i]<2. && varxi[i]>0.) {
    //cout << r[i]<<" "<<xip[i]<<" "<<sqrt(varxi[i])<<endl;
    DVector x(NFIT);
    x[0] = 1.; 
    for(int j=1;j<NFIT;j++) x[j] = r[i]*x[j-1];
    //cout <<"x = "<<x<<endl;
    DVector temp = x/varxi[i];
    //cout <<"temp = "<<temp<<endl;
    A += OuterProduct(x,temp);
    //cout <<"A += "<<OuterProduct(x,temp)<<endl;
    B += xip[i]*temp;
    C += xim[i]*temp;
  }
  //cout << "A = "<<A<<endl;
  //cout << "B = "<<B<<endl;
  //cout << "C = "<<C<<endl;
  DVector fp = B/A;
  DVector fm = C/A;
  //cout << "fp = "<<fp<<endl;
  //cout << "fm = "<<fm<<endl;
  
  for(uint i=0;i<r.size();i++) if (r[i]<8.) {
    DVector x(NFIT);
    x[0] = 1.; 
    for(int j=1;j<NFIT;j++) x[j] = r[i]*x[j-1];
    double fitxip = fp*x;
    double fitxim = fm*x;
    cout << r[i] <<' '<<xip[i]<<' '<<fitxip<<' '<<xim[i]<<' '<<fitxim<<endl;
  }
  return 0;
}
